#ifndef SOUNDLOADER
#define SOUNDLOADER

#include <fmod.hpp>
#include <fmod_errors.h>
#include <map>
#include <iostream>
#include <QString>
using namespace std;

class sound
{
	public:
		sound();
		~sound();

		static void init();
		static void shutdown();
		bool load(const char *filename);
		bool loadstream(const char *filename);
		void play();
		void pause();

		FMOD::Channel* getChannel() {return channel;};
		float getFrequency(){return frequency;};
		int getOffset(){return offset;};
		float getLength();
		int getPosition();
		FMOD::Sound* getSoundId(){return soundid;};
		QString getPath() {return path;};

		void setFrequency(float newfreq);
		void setPitch(float f);
		void setVolume(float f) {channel->setVolume(f);};
		void addOffset(int increment_ms) ;
		void setPosition(unsigned int ms) ;
		void setLoop(int i) {soundid->setLoopCount(i);};
		bool isPlaying() {bool b; channel->isPlaying(&b); return b;}

		static FMOD::System *s_system;

	private:
		FMOD::Sound *soundid;
		FMOD::DSP *bpmpitch;
		FMOD::DSPConnection *_pitchConnection;
		FMOD::Channel *channel;
		float frequency;
		int offset;
		QString path;

};

#endif
